package org.loong.crypto.service.software.provider.digest;

import org.loong.crypto.common.exception.CryptoException;
import org.loong.crypto.core.algorithm.MessageDigestAlgorithm;
import org.loong.crypto.service.core.provider.MessageDigest;
import org.loong.crypto.service.core.provider.impl.BaseMessageDigestProvider;

import cn.hutool.crypto.digest.Digester;

/**
 * Generic Message digest.
 */
public class GenericMessageDigest extends BaseMessageDigestProvider implements MessageDigest  {

    @Override
    public byte[] digest(MessageDigestAlgorithm algorithm, byte[] data) throws CryptoException {
        Digester digester = new Digester(algorithm.getName());
        return digester.digest(data);
    }
}
